package cn.edu.hnnu.a.rentacar.dao.hibernateimpl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import cn.edu.hnnu.a.rentacar.beans.CheckRecord;
import cn.edu.hnnu.a.rentacar.idao.ICheckRecordDAO;
import cn.edu.hnnu.a.rentacar.util.HibernateUtil;

public class CheckRecordDAOHibernateImpl implements ICheckRecordDAO {
	private static CheckRecordDAOHibernateImpl instance;
	
	private CheckRecordDAOHibernateImpl(){
		
	}
	
	public static CheckRecordDAOHibernateImpl getInstance(){
		if(null==instance){
			instance = new CheckRecordDAOHibernateImpl();
		}
		return instance;
	}
	
	
	
	@Override
	public void addCheckRecord(CheckRecord checkRecord) {
		SessionFactory factory = HibernateUtil.getSessionFactory();
		Session session = factory.openSession();
		Transaction tran = session.beginTransaction();
		session.save(checkRecord);
		tran.commit();
		session.close();
	}

}
